
**************************************************************************
*** Figure 3: Land Certification and Household Welfare using Callaway and Sant'Anna's estimator
**************************************************************************
clear
use "Build/LCP.dta"

csdid CON , ivar(countyreal) time(year) gvar(first_treat) method(dripw) cluster(countyID) long2 wboot rseed(1)//consumption
qui: estat event
csdid_plot
estat simple
csdid ASS , ivar(countyreal) time(year) gvar(first_treat) method(dripw) cluster(countyID) long2 wboot rseed(1)//asset
qui: estat event
csdid_plot
estat simple
csdid INC , ivar(countyreal) time(year) gvar(first_treat) method(dripw) cluster(countyID) long2 wboot rseed(1)//income
qui: estat event
csdid_plot
estat simple
csdid HEA , ivar(countyreal) time(year) gvar(first_treat) method(dripw) cluster(countyID) long2 wboot rseed(1)//health
qui: estat event
csdid_plot
estat simple
csdid RES , ivar(countyreal) time(year) gvar(first_treat) method(dripw) cluster(countyID) long2 wboot rseed(1)//resilience
qui: estat event
csdid_plot
estat simple

restore
**************************************************************************
*** table 2: Land Certification and Household Income
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography

reghdfe INC did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Income
est store m1
reghdfe AGINC did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Agriculture Income
est store m2
reghdfe WGINC did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Wage Income
est store m3
reghdfe BUINC did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Business Income
est store m4
esttab m1 m2 m3 m4 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 3: Land Certification and Household Consumption
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography

reghdfe CON did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Consumption
est store m1
reghdfe FoodCON did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Food Consumption
est store m2
reghdfe Non-FoodCON did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Non-Food Consumption
est store m3
reghdfe EDUCON did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Education Expenditure
est store m4
reghdfe HEACON did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Health Expenditure
est store m5
reghdfe HEA did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Physical Health
est store m6
esttab m1 m2 m3 m4 m5 m6,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 4: Land Certification and Household Assets
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography

reghdfe ASS did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Total assets
est store m1
reghdfe AgriASS did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Productive assets (Agri)
est store m2
reghdfe BusASS did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Productive assets (Bus)
est store m3
esttab m1 m2 m3 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 5: Land Certification and Household Resilience
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography

reghdfe Resilience did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Resilience
est store m1
reghdfe Meanequation did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Mean equation
est store m2
reghdfe Varianceequation did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Variance equation
est store m3
esttab m1 m2 m3 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 6: Land Certification and Land Rental Market Participation
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
xtlogit Rendout did $xlist i.countyID i.year i.province#i.year,fe//Rend out
margins i.certi
margins r.certi
est store m1
reghdfe Landpriceout did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Land price(out)
est store m2
xtlogit Rendin did $xlist i.countyID i.year i.province#i.year,fe//Rend in
margins i.certi
margins r.certi
est store m3
reghdfe Landpricein did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Land price(in)
est store m4
reghdfe LandArea did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Land price(in)
est store m5
esttab m1 m2 m3 m4 m5 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 7: Land Certification and Labor Allocation
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
xtlogit Agriwork did $xlist i.countyID i.year i.province#i.year,fe//Agri-work
margins i.certi
margins r.certi
est store m1
xtlogit Nonfarmwork did $xlist i.countyID i.year i.province#i.year,fe//Non-farm work
margins i.certi
margins r.certi
est store m2
xtlogit Business did $xlist i.countyID i.year i.province#i.year,fe//Business
margins i.certi
margins r.certi
est store m3
esttab m1 m2 m3 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 8: Land Certification and Access to Credit
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
reghdfe Creditagriculture did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Agri-work
est store m1
reghdfe Credit-business did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Non-farm work
est store m2
esttab m1 m2 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 9: Land Certification and Investment
**************************************************************************
preserve
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
reghdfe AgriculturalInputs did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Agricultural Inputs
est store m1
reghdfe BusinessAssets did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Business Assets
est store m2
esttab m1 m2 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table 10: Land Certification, Consumption and Resilience: By Gender and Economic status
**************************************************************************
preserve
*resilience
global xlist age age2 edu  riskattu married health shock gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
reghdfe Resilience did $xlist if gender==1, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
reghdfe Resilience did $xlist if gender==0, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
set seed 01
bdiff,group(gender) model(reghdfe Resilience did $xlist ///
, absorb(i.countyID i.year i.province#i.year) cluster(countyID)) reps(500) bs first detail//gender

reghdfe Resilience did $xlist if poverty==1, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
reghdfe Resilience did $xlist if poverty==0, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
set seed 01
bdiff,group(poverty) model(reghdfe Resilience did $xlist ///
, absorb(i.countyID i.year i.province#i.year) cluster(countyID)) reps(500) bs first detail//poverty

*consumption
reghdfe CON did $xlist if gender==1, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
reghdfe CON did $xlist if gender==0, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
set seed 01
bdiff,group(gender) model(reghdfe CON did $xlist ///
, absorb(i.countyID i.year i.province#i.year) cluster(countyID)) reps(500) bs first detail//gender

reghdfe CON did $xlist if poverty==1, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
reghdfe CON did $xlist if poverty==0, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
set seed 01
bdiff,group(poverty) model(reghdfe CON did $xlist ///
, absorb(i.countyID i.year i.province#i.year) cluster(countyID)) reps(500) bs first detail//poverty


**************************************************************************
*** table A3: Determinant of County Land Reform Timing
**************************************************************************
clear
use "Build/LCPcounty.dta"
global xlist GDP Industry Population Topography Public expenditure Deposit Loanbalance Localacreage 
xtlogit LandReform  $xlist i.countyID i.year ,fe
margins i.certi
margins r.certi
est store m1
xtreg LandReformyear $xlisti.countyID i.year ,fe
est store m2
esttab m1 m2 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table A4: The effect of land certification and negative shock on household resilience 
**************************************************************************
clear
use "Build/LCP.dta"
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
reghdfe resilience did*shock $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m1
esttab m1  ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table A5: Land Certification and Land Rental Market Participation (OLS)
**************************************************************************
clear
use "Build/LCP.dta"
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
reghdfe Rendout did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m1
reghdfe Rendin did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m2
esttab m1 m2 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table A6:Mechanisms: Labor Allocation and Income
**************************************************************************
clear
use "Build/LCP.dta"
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
xtlogit Part-time did $xlist i.countyID i.year i.province#i.year ,fe
est store m1
xtlogit Localemployment did $xlist i.countyID i.year i.province#i.year,fe
est store m2
esttab m1 m2 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table A7: Land Certification and Land Rental Market Participation (OLS)
**************************************************************************
clear
use "Build/LCP.dta"
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
reghdfe Agriwork did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m1
reghdfe Nonfarmwork did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m2
reghdfe Business did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m3
esttab m1 m2 m3 ,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** table A8: Land Certification and Land Rental Market Participation (OLS)
**************************************************************************
clear
use "Build/LCP.dta"
set seed 0001
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
gen tmp = runiform()
sort tmp
psestimate certi $xlist, nolin genlor(logodds)
reghdfe CON did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m1
reghdfe ASS did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m2
reghdfe INC did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m3
reghdfe HEA did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m4
reghdfe RES did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)
est store m5
esttab m1 m2 m3 m4 m5,b(%9.4f) se nogap compress scalars(r2 N) mtitle star(* 0.1 ** 0.05 *** 0.01) 
restore

**************************************************************************
*** Figure A1-A5: Land Certification and Income
**************************************************************************
**TWFE OLS
clear
use "Build/LCP.dta"
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
gen event = year - certiyear
gen post=1 if certiyear>0
recode post (1=.) if event==.
recode post (.=0) 
tab event
forvalues i=5(-1)1{
  gen pre`i'=(event==-`i'& post==1)
}

gen current=(event==0 & post==1)

forvalues i=1(1)5{
  gen post`i'=(event==`i'& post==1)
}
drop  pre1
reghdfe CON pre* current post*  $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//consumption
coefplot, keep(pre5 pre4 pre3 pre2  current post1 post2 post3 post4 post5 ) vertical addplot(line @b @at) yline(0) levels(95)
reghdfe ASS pre* current post*  $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//asset
coefplot, keep(pre5 pre4 pre3 pre2  current post1 post2 post3 post4 post5 ) vertical addplot(line @b @at) yline(0) levels(95)
reghdfe INC pre* current post*  $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//income
coefplot, keep(pre5 pre4 pre3 pre2  current post1 post2 post3 post4 post5 ) vertical addplot(line @b @at) yline(0) levels(95)
reghdfe HEA pre* current post*  $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//health
coefplot, keep(pre5 pre4 pre3 pre2  current post1 post2 post3 post4 post5 ) vertical addplot(line @b @at) yline(0) levels(95)
reghdfe RES pre* current post*  $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//resilience
coefplot, keep(pre5 pre4 pre3 pre2  current post1 post2 post3 post4 post5 ) vertical addplot(line @b @at) yline(0) levels(95)

**Sun & Abraham (SA) (2021)
eventstudyinteract CON g_5-g5, cohort(first_union) control_cohort(never_union) ///consumption
covariates(age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography) ///
absorb(i.countyID i.year i.province#i.year) cluster(countyID)

eventstudyinteract ASS g_5-g5, cohort(first_union) control_cohort(never_union) ///asset
covariates(age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography) ///
absorb(i.countyID i.year i.province#i.year) cluster(countyID)

eventstudyinteract INC g_5-g5, cohort(first_union) control_cohort(never_union) ///income
covariates(age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography) ///
absorb(i.countyID i.year i.province#i.year) cluster(countyID)

eventstudyinteract HEA g_5-g5, cohort(first_union) control_cohort(never_union) ///health
covariates(age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography) ///
absorb(i.countyID i.year i.province#i.year) cluster(countyID)

eventstudyinteract RES g_5-g5, cohort(first_union) control_cohort(never_union) ///resilience
covariates(age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography) ///
absorb(i.countyID i.year i.province#i.year) cluster(countyID)

**Borusyak et al.（2024）
drop if event<-4 
did_imputation CON countyID year first_year, allhorizons pretrends(5) autosample 
fe(countyID year) cluster(countyID)           ///consumption
did_imputation ASS countyID year first_year, allhorizons pretrends(5) autosample 
fe(countyID year) cluster(countyID)                   ///asset
did_imputation INC countyID year first_year, allhorizons pretrends(5) autosample 
fe(countyID year) cluster(countyID)                  ///income
did_imputation HEA countyID year first_year, allhorizons pretrends(5) autosample 
fe(countyID year) cluster(countyID)                  ///health
did_imputation RES countyID year first_year, allhorizons pretrends(4) autosample 
fe(countyID year) cluster(countyID)                  ///resilience

**Gardner (2022)
did2s CON, first_stage(i.countyID i.year) second_stage(pre* current post* )  treatment(certi) cluster(countyID) ///consumption
did2s ASS, first_stage(i.countyID i.year) second_stage(pre* current post* )  treatment(certi) cluster(countyID) ///asset
did2s INC, first_stage(i.countyID i.year) second_stage(pre* current post* )  treatment(certi) cluster(countyID) ///income
did2s HEA, first_stage(i.countyID i.year) second_stage(pre* current post* )  treatment(certi) cluster(countyID) ///health
did2s RES, first_stage(i.countyID i.year) second_stage(pre* current post* )  treatment(certi) cluster(countyID) ///resilience

**************************************************************************
*** Figure A6: Placebo test
**************************************************************************
clear
use "Build/LCP.dta"
global xlist age age2 edu gender riskattu married health shock poverty gdp Population Totalpublicexpenditure Totaldepositbalance Totalloanbalance Topography
reghdfe CON did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Income
estimates store estimate
didplacebo estimate, treatvar(did) pbomix(2) seed(1)

reghdfe ASS did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//asset
estimates store estimate
didplacebo estimate, treatvar(did) pbomix(2) seed(1)

reghdfe INC did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//Income
estimates store estimate
didplacebo estimate, treatvar(did) pbomix(2) seed(1)

reghdfe HEA did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//health
estimates store estimate
didplacebo estimate, treatvar(did) pbomix(2) seed(1)

reghdfe RES did $xlist, absorb(i.countyID i.year i.province#i.year) cluster(countyID)//resilience
estimates store estimate
didplacebo estimate, treatvar(did) pbomix(2) seed(1)





